<?php

// 9/12/2009: immanuel192 write this action

// this action will delete selected order

if (!defined("EXPONENT")) exit("");
  global $user;
  global $db;
// get order id
  $id=-1;
if (isset($_GET['id'])) $id=intval($_GET['id']);
// check order id
 $temp=$db->selectObject("orders","id = {$id}");
 if (!$temp || ((!$user->is_admin || !$user->is_acting_admin) && ($temp->user_id != $user->id))) $id=-1;
if (exponent_sessions_loggedIn() && ($id>0)){
  // first, remove all item in this order
  $db->delete("order_items","order_id = {$id}");
  $db->delete("orders","id = {$id}");
  exponent_flow_redirect();
}
else
{
 // redirect to homepage
	echo "<script language=javascript>document.location='".URL_BASE."/index.php';</script>";
	die();
}

?>
